trigger:
  batch: true
  branches:
    include:
    - release/*.*
  paths:
    include:
    - '*'
    - src/libraries/System.Private.CoreLib/*
    exclude:
    - '**.md'
    - .devcontainer/*
    - .github/*
    - docs/*
    - LICENSE.TXT
    - PATENTS.TXT
    - THIRD-PARTY-NOTICES.TXT
    - src/installer/*
    - src/libraries/*
    - eng/pipelines/installer/*
    - eng/pipelines/libraries/*
    - eng/pipelines/runtime.yml

schedules:
  - cron: "0 9,18,1 * * *" # run at 9:00, 18:00 and 01:00 (UTC) which is 2:00, 11:00 and 18:00 (PST).
    displayName: runtime-coreclr-outerloop default schedule
    branches:
      include:
      - main
    always: false # run only if there were changes since the last successful scheduled run.

variables:
  - template: /eng/pipelines/common/variables.yml

extends:
  template:  /eng/pipelines/common/templates/pipeline-with-resources.yml
  parameters:
    stages:
    - stage: Build
      jobs:

      #
      # Debug builds
      #
      - template: /eng/pipelines/common/platform-matrix.yml
        parameters:
          jobTemplate: /eng/pipelines/common/global-build-job.yml
          buildConfig: debug
          platforms:
          - linux_arm
          - linux_arm64
          - linux_musl_arm64
          - linux_musl_x64
          - linux_x64
          - osx_arm64
          - osx_x64
          - windows_arm64
          jobParameters:
            buildArgs: -s clr -c $(_BuildConfig)
            postBuildSteps:
              - template: /eng/pipelines/coreclr/templates/build-native-test-assets-step.yml
            extraVariablesTemplates:
              - template: /eng/pipelines/common/templates/runtimes/native-test-assets-variables.yml
                parameters:
                  testGroup: outerloop

      #
      # Release builds
      #
      - template: /eng/pipelines/common/platform-matrix.yml
        parameters:
          jobTemplate: /eng/pipelines/common/global-build-job.yml
          buildConfig: release
          platforms:
          - linux_arm
          - linux_musl_arm64
          - linux_x64
          - osx_arm64
          - osx_x64
          - windows_x86
          jobParameters:
            buildArgs: -s clr -c $(_BuildConfig)
            postBuildSteps:
              - template: /eng/pipelines/coreclr/templates/build-native-test-assets-step.yml
            extraVariablesTemplates:
              - template: /eng/pipelines/common/templates/runtimes/native-test-assets-variables.yml
                parameters:
                  testGroup: outerloop

      #
      # Checked builds
      #
      - template: /eng/pipelines/common/platform-matrix.yml
        parameters:
          jobTemplate: /eng/pipelines/common/global-build-job.yml
          buildConfig: checked
          platformGroup: all
          platforms:
          # It is too early to include osx_arm64 in platform group all
          # Adding it here will enable it also
          - osx_arm64
          jobParameters:
            buildArgs: -s clr+libs -c $(_BuildConfig) -lc Release
            postBuildSteps:
              - template: /eng/pipelines/coreclr/templates/build-native-test-assets-step.yml
              - template: /eng/pipelines/common/upload-artifact-step.yml
                parameters:
                  rootFolder: $(Build.SourcesDirectory)/artifacts/bin
                  includeRootFolder: false
                  archiveType: $(archiveType)
                  archiveExtension: $(archiveExtension)
                  tarCompression: $(tarCompression)
                  artifactName: BuildArtifacts_$(osGroup)$(osSubgroup)_$(archType)_$(_BuildConfig)
                  displayName: Build Assets
            extraVariablesTemplates:
              - template: /eng/pipelines/common/templates/runtimes/native-test-assets-variables.yml
                parameters:
                  testGroup: outerloop

      #
      # Checked test builds
      #
      - template: /eng/pipelines/common/platform-matrix.yml
        parameters:
          jobTemplate: /eng/pipelines/common/templates/runtimes/build-test-job.yml
          buildConfig: checked
          platforms:
          - CoreClrTestBuildHost # Either osx_x64 or linux_x64
          testGroup: outerloop

      #
      # Checked JIT test runs
      #
      - template: /eng/pipelines/common/platform-matrix.yml
        parameters:
          jobTemplate: /eng/pipelines/common/templates/runtimes/run-test-job.yml
          buildConfig: checked
          platformGroup: all
          platforms:
          # It is too early to include osx_arm64 in platform group all
          # Adding it here will enable it to also run this test
          - osx_arm64
          helixQueueGroup: ci
          helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
          jobParameters:
            testGroup: outerloop
            liveLibrariesBuildConfig: Release
            unifiedArtifactsName: BuildArtifacts_$(osGroup)$(osSubgroup)_$(archType)_$(_BuildConfig)

      #
      # Checked R2R test runs
      #
      - template: /eng/pipelines/common/platform-matrix.yml
        parameters:
          jobTemplate: /eng/pipelines/common/templates/runtimes/run-test-job.yml
          buildConfig: checked
          platforms:
          - linux_arm64
          - linux_musl_x64
          - linux_musl_arm64
          - linux_x64
          - osx_x64
          - windows_x64
          - windows_x86
          - windows_arm64
          helixQueueGroup: ci
          helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
          jobParameters:
            testGroup: outerloop
            readyToRun: true
            displayNameArgs: R2R_CG2
            liveLibrariesBuildConfig: Release
            unifiedArtifactsName: BuildArtifacts_$(osGroup)$(osSubgroup)_$(archType)_$(_BuildConfig)

      #
      # Formatting
      #
      - template: /eng/pipelines/common/platform-matrix.yml
        parameters:
          jobTemplate: /eng/pipelines/coreclr/templates/format-job.yml
          platforms:
          - linux_x64
          - windows_x64

      #
      # PAL Tests
      #
      - template: /eng/pipelines/common/platform-matrix.yml
        parameters:
          helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
          jobTemplate: /eng/pipelines/common/global-build-job.yml
          buildConfig: Debug
          platforms:
          - linux_x64
          - linux_musl_x64
          - linux_arm64
          - linux_musl_arm64
          - osx_x64
          - osx_arm64
          jobParameters:
            buildArgs: -s clr.paltests+clr.paltestlist
            nameSuffix: PALTests
            postBuildSteps:
              - template: /eng/pipelines/coreclr/templates/run-paltests-step.yml
